<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'left.jsp' starting page</title>
		<link href="./css/xtab.css" rel="stylesheet" type="text/css" />
	</head>

	<body>
		<html:form action="/catalog.do">
		<html:hidden property="catalog.parentId" value="${p_id}"/>
		
			<table width="100%" align="center" cellspacing="0">
				<tr>

					<th class="tableTitle"  width="70%">
						栏目名称
					</th>
					<th class="tableTitle" width="10%">
						栏目顺序
					</th>
					<th class="tableTitle" width="10%">
						修改
					</th>
					<th class="tableTitle" width="10%">
						删除
					</th>
				</tr>
				<logic:iterate id="c" name="catalogList">
					<tr>
						<td class="tableElement">
							<a href="javascript:getChildNode('<bean:write property="catalogId" name="c" />');">
								<bean:write property="catalogName" name="c" />
							</a>
						</td>

						<td class="tableElement">
							<input type="hidden" name="c_id" value="${c.catalogId }">
							<input type="text" name="order" value="${c.catalogOrder }" size="4">
						</td>
						<td class="tableElement">
							<img src="<%=path%>/images/update.gif"
								onclick="updt('<bean:write property="catalogId" name="c"/>')">
						</td>
						<td class="tableElement">
							<img src="<%=path%>/images/delete.gif"
								onclick="del('<bean:write property="catalogId" name="c"/>')">
						</td>
					</tr>


				</logic:iterate>
			</table>
			<br>
			<div align="center"><input type="button" class="button" value="保存排序" onclick="orderCatalog()"> <input type="button" class="button" value="新增栏目" onclick="addCatalog()"></div>
<script>
	function getChildNode(val)
	{
		var f=document.catalogForm;
		f.action="catalog.do?method=toShowCatalog&p_id="+val;
		f.submit();
	}
  function updt(val)
  {
  		var f=document.catalogForm;
		f.action="catalog.do?method=toUpdateCatalog&c_id="+val;
		f.submit();
  }
  function del(val)
  {
  		var f=document.catalogForm;
		f.action="catalog.do?method=delCatalog&c_id="+val;
		f.submit();
  }
  
  function addCatalog()
  {
  		var f=document.catalogForm;
		f.action="catalog.do?method=toAddCatalog";
		f.submit();
  }
  function orderCatalog()
  {
  		var f=document.catalogForm;
		f.action="catalog.do?method=orderCataglog";
		f.submit();
    
  }
  </script>
		</html:form>
	</body>
</html>

